#include<func.h>
//mmap接口实现文件映射
int main(int argc,char*argv[])
{
    ARGS_CHECK(argc,2)
    int fd;
    int ret;
    char *p;
    fd=open(argv[1],O_RDWR);
    ERROR_CHECK(fd,-1,"open");
    p=(char*)mmap(NULL,5,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
    // ret=ftruncate(fd,atoi(argv[2]));
    ERROR_CHECK(p,(char*)-1,"mmap");
    printf("%s\n",p);
    p[0]='w';
    p[1]='o';
    p[2]='r';
    p[3]='l';
    p[4]='d';
    ret=munmap(p,5);
    ERROR_CHECK(ret,-1,"munmap");
    return 0;

}